<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/vue.js"></script>
  </head>
  <body>
    <div id="root">
      <h2>a:{{numbers.a}}</h2>
      <button @click="numbers.a++">点我改变a的值</button>

      <h2>b:{{numbers.b}}</h2>
      <button @click="numbers.b++">点我改变a的值</button>
    </div>
    <!-- 

     -->
    <script type="text/javascript">
      Vue.config.productionTip = false
      const vm = new Vue({
        el: '#root',
        data: {
          numbers: {
            a: 1,
            b: 2,
          },
        },
        //监视属性的简写方式
        /*      watch: {
          'numbers.a'() {
            console.log('numbers.a的值改变了')
          },
        }, */
      })

      // 监视属性的简写方式
      vm.$watch('numbers.a', function () {
        console.log('numbers.a的值改变了')
      })
    </script>
  </body>
</html>
